home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
MATHS
/
ARCAUT
/
Automatons
/
Life
< prev
next >
Wrap
Text File
|
1991-07-27
|
2KB
|
70 lines
AUTOMATON*
Life
This must be the most well known of all Cellular Automatons, originally
devised by John Horton Conway. It is a two state Moore neighbourhood
automaton; the two states are called dead & alive. The rules governing
growth are: If a living cell has two or three living neighbours, it remains
alive, otherwise it is considered to be overcrowded or undernourished &
dies. If a dead cell has exactly three living neighbours, a live cell will
be born, otherwise it remains dead. 'Life' supports much complexity & is
actually equivalent to a Turing machine (it could be used to solve any
computable problem - like wireworld & BBM). This implementation selects one
of two initial configurations, one of which is known as a Glider Gun; a
prize had been offered & was won for the discovery of this object. Try a
40x30 window to view the gun.
INITIALISATION*
10DEF PROCdo
20*SetEval wrap off
30*SetEval border dead
40ENDPROC
SCREEN*
10DEF PROCdo
20DIM buf% 256:SYS "OS_ReadVarVal","alive",buf%,256:c%=FNacol(!buf%)
30GCOL c% AND 63 TINT c%
40CASE RND(2) OF
50WHEN 1
60MOVE-8,0:DRAW BY 19,0:DRAW BY 0,-4
70MOVE BY -19,-4:DRAW BY 0,0
80WHEN 2
90LOCAL DATA
100RESTORE+ 0
110DATA 123456789#
120DATA 123456789##
130DATA 1234##789A##
140DATA ##34##789A###
150DATA ##34##789A##
160DATA 123456789##
170DATA 123456789#
180DATA #
190DATA #2#
200DATA 1#2#
210DATA 1#23#567##
220DATA 1#2#4567##
230DATA #2#
240DATA #
250FOR q%=16 TO -8 STEP -4:READ q$
260FOR w%=1 TO LEN q$:IF MID$(q$,w%,1)="#" POINT 4*w%-76,q%
270NEXT:NEXT
280FOR q%=8 TO -16 STEP -4:READ q$
290FOR w%=1 TO LEN q$:IF MID$(q$,w%,1)="#" POINT 4*w%+28,q%
300NEXT:NEXT
310ENDCASE
320ENDPROC
CODE*
( READ_NEIG
alive SCOUNT_NEIG
CELL IF ( DUP 2 = IF (alive ==)
3 = IF (alive ==)
dead == )
ELSE ( 3 = IF (alive ==)
ELSE ( dead ==)) )
END*